function shu(){
    let url = location.href
let s =    decodeURIComponent(url)
url = s.substring(s.indexOf('?') + 1)
let arr = url.split('=')
let keyword = arr[1]
return keyword
}
function search1(){
    let keyword=shu()
     ajax({
        method: 'get',
        url: 'http://api.yuguoxy.com/api/shop/search',
        data: {
            keyword
        },
        success: function (data) {
            let {
                resultCode,
                resultInfo
            } = data //解构赋值
            if (resultCode == 1) {
                let list = resultInfo.list
                   $('.kk').html($('input[type="text"]').val())
             
                showproductlist(list)

            } else {
                alert('失败')
            }

        }

    })
}

function showproductlist(list) {
    let str = list.map(item => {
        return ` <div onclick="onDetail(${item.id})">
        <img src="${item.picture}" alt="">
        <p>${item.shop}</p>
        <span>淘宝</span><span>包邮</span>
        <ul>
            <li class="color">￥${item.price}</li>
           
        </ul>
    </div>`
    }).join('')
   
    let contents = document.querySelector('.contents')
    contents.innerHTML = str
   
}
function onDetail(id) {
    location.href = '../pages/banner.html?id=' + id
}  
function index0() {

    location.href = '../pages/index.html'
}
function index1() {
    let contert = document.querySelector('.contert')
    contert.innerHTML = location.href = '../pages/index11.html'

}

function index2() {

    location.href = '../pages/index12.html'
}

function index3() {

    location.href = '../pages/index13.html'
}
function search(){
     ajax({
        method: 'get',
        url: 'http://api.yuguoxy.com/api/shop/search',
        data: {
            keyword:$('input[type="text"]').val(),
        },
        success: function (data) {
            let {
                resultCode,
                resultInfo
            } = data //解构赋值
            if (resultCode == 1) {
                let list = resultInfo.list
                   
                $('.kk').html($('input[type="text"]').val())
                showproductlists(list)

            } else {
                alert('失败')
            }

        }

    })
}
function showproductlists(list) {
    let str = list.map(item => {
        return ` <div onclick="onDetail(${item.id})">
        <img src="${item.picture}" alt="">
        <p>${item.shop}</p>
        <span>淘宝</span><span>包邮</span>
        <ul>
            <li class="color">￥${item.price}</li>
           
        </ul>
    </div>`
    }).join('')
   
    let contents = document.querySelector('.contents')
    contents.innerHTML = str
   
}
search1()